use std::io;
use std::num::ParseIntError;
#[derive(Debug)]
pub enum MyErrs {
    ReqwestError(reqwest::Error),
    JsonError(serde_json::Error),
    CommError(io::Error),
    LackArg(String),
    UnkownCom(String),
    ThreadErrs(Vec<MyErrs>),
    UnkownJsonParse,
    ParseErr,
    ThreadsNotFinish,
}
impl MyErrs {
    pub fn count(&self) -> u64 {
        match self {
            Self::ThreadErrs(vec) => vec.len() as u64,
            _ => 1,
        }
    }
    pub fn push_to_vec(self, vector: &mut Vec<Self>) {
        match self {
            Self::ThreadErrs(mut vec) => vector.append(&mut vec),
            _ => vector.push(self),
        }
    }
}
impl From<reqwest::Error> for MyErrs {
    fn from(error: reqwest::Error) -> Self {
        Self::ReqwestError(error)
    }
}
impl From<serde_json::Error> for MyErrs {
    fn from(error: serde_json::Error) -> Self {
        Self::JsonError(error)
    }
}
impl From<ParseIntError> for MyErrs {
    fn from(_error: ParseIntError) -> Self {
        Self::ParseErr
    }
}
impl From<io::Error> for MyErrs {
    fn from(e: io::Error) -> Self {
        MyErrs::CommError(e)
    }
}
